package cn.demoncat.util.word.entity;

import cn.demoncat.util.word.constant.WordGenConstant;

import java.util.ArrayList;
import java.util.List;

/**
 * Word文档
 *
 * @author 延晓磊
 * @since 2021年04月10日
 */
public class WordDocument {

    /**
     * 纸张：默认WordGenConstant.Paper.A4
     */
    private String paper;
    /**
     * 页脚：1页码，0无，null无
     */
    private String footer;
    /**
     * 页眉：文本
     */
    private String header;
    /**
     * 页眉 - 边框下划线：1有，0无，null无
     */
    private String headerBorder;
    /**
     * 内容
     */
    private List<WordContent> contents;

    /**
     * 添加内容 - 段落
     *
     * @return 段落
     *
     * @author 延晓磊
     * @since 2021年04月12日
     */
    public WordParagraph addParagraph(){
        if (this.getContents() == null) {
            this.setContents(new ArrayList<>());
        }
        WordContent content = new WordContent();
        content.setType(WordGenConstant.ContentType.PARAGRAPH);
        content.setParagraph(new WordParagraph());
        this.getContents().add(content);
        return content.getParagraph();
    }

    /**
     * 添加内容 - 表格
     *
     * @return 表格
     *
     * @author 延晓磊
     * @since 2021年04月12日
     */
    public WordTable addTable(){
        if (this.getContents() == null) {
            this.setContents(new ArrayList<>());
        }
        WordContent content = new WordContent();
        content.setType(WordGenConstant.ContentType.TABLE);
        content.setTable(new WordTable());
        this.getContents().add(content);
        return content.getTable();
    }


    public String getPaper() {
        return paper;
    }

    public void setPaper(String paper) {
        this.paper = paper;
    }

    public String getFooter() {
        return footer;
    }

    public void setFooter(String footer) {
        this.footer = footer;
    }

    public String getHeader() {
        return header;
    }

    public void setHeader(String header) {
        this.header = header;
    }

    public String getHeaderBorder() {
        return headerBorder;
    }

    public void setHeaderBorder(String headerBorder) {
        this.headerBorder = headerBorder;
    }

    public List<WordContent> getContents() {
        return contents;
    }

    public void setContents(List<WordContent> contents) {
        this.contents = contents;
    }
}
